/**
 * Created by Administrator on 2017/2/12.
 */
import { Component } from '@angular/core';
import { ReService } from './register.serve';
import { Router, ActivatedRoute, Params } from '@angular/router';

@Component({
  moduleId: module.id,
  selector: 'my-register',
  templateUrl: 'register.html',
  providers:[ReService]
})
export class RegisterComponent {
  constructor(private reService:ReService,
              private route: ActivatedRoute,
              private router: Router,
  ) {}
  public  name1:string='';
  public  name2:string='';
  public sgin;
  public errMessage:string;
  addHero (username:string, pwd:string, repwd:string, email:string, language:string, address:string,vocation:string,company:string) {
    if (!username || !pwd || !repwd || !email || !language || !address) { return; }
    this.reService.register(username, pwd, repwd, email, language, address,vocation,company)
      .subscribe(
      res => this.sgin = res,
      error =>  this.errMessage = <any>error);
      console.log(this.sgin);
      this.router.navigate(['/main']);
  }
}
